package com.kgc.sbt.provider;

import com.alibaba.dubbo.config.annotation.Service;
import com.kgc.sbt.api.OrderItemApi;
import com.kgc.sbt.domain.OrderItem;
import com.kgc.sbt.domain.OrderItemExample;
import com.kgc.sbt.mapper.OrderItemMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;

import java.util.List;
/**
 * @author Shan
 * @date 2021/6/22
 * @return 
 * @description 
 */
 
@Service
@Slf4j
public class OrderItemProvider implements OrderItemApi {
    @Autowired
    private OrderItemMapper orderItemMapper;
    
    @Override
    @Async
    public void insertOrderItem(List<OrderItem> orderItemList) {
        for (int a=0;a<orderItemList.size();a++){
            orderItemMapper.insert(orderItemList.get(a));
        }
        log.info("------ 异步执行插入商品详情 ------");
    }

    @Override
    public List<OrderItem> queryOrderItemByOrderNumber(String orderNumber) {
        OrderItemExample orderItemExample=new OrderItemExample();
        OrderItemExample.Criteria criteria=orderItemExample.createCriteria();
        criteria.andOrderNumberEqualTo(orderNumber);
        orderItemExample.or(criteria);
        return orderItemMapper.selectByExample(orderItemExample);
    }
}
